// 图像腐蚀示例
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <iostream>

using namespace cv;
using namespace std;

int main(int argc, char** argv) {

  // 载入图片
  if (argc != 2) {
    cout << "arg1 is image files path" << endl;
    return -1;
  }

  Mat img_src = imread(argv[1]);
  if (img_src.empty()) {
    cout << "image path is null" << endl;
    return -1;
  }

  // 缩小图片尺寸
  Mat img_proc_src;
  resize(img_src, img_proc_src, Size(img_src.cols/2, img_src.rows/2));
  imshow("origin image: ", img_proc_src);
  
  // erosion process
  Mat element = getStructuringElement(MORPH_RECT, Size(10, 10));
  Mat img_dst;
  erode(img_proc_src, img_dst, element);
  
  imshow("erosion image: ", img_dst);

  waitKey(0);
  
  return 0;
}